home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / dskutil / msort112.zip / MSORT.DOC < prev    next >
Text File  |  1995-01-21  |  16KB  |  388 lines

  1.                         MSORT -- Master Sort Program
  2.  
  3.                         SSORT -- Speedy Sort Program
  4.  
  5.  
  6.                                 Version 1.12
  7.  
  8.                This document and the associated software are
  9.          Copyright 1994 by Martin Katz, Ph.D. all rights reserved.
  10.  
  11.  
  12.                                   PURPOSE
  13.  
  14. MSORT and SSORT are superior text file sorting programs for DOS. MSORT and
  15. SSORT are faster, easier to use and more powerful than the sort program
  16. included with MS-DOS or PC-DOS. In addition, while DOS sort is limited to
  17. small files, MSORT can sort huge files.
  18.  
  19. MSORT and SSORT allow you to sort files either alphabetically or numerically. You can also define the columns that define the sorting keys, sort in
  20. reverse, ignore spaces while sorting, and treat upper and lower case as the
  21. same, and much more. If you wish, MSORT will remove duplicate lines and/or
  22. blank lines.
  23.  
  24. These are fully functional programs with no shareware reminders. MSORT and
  25. SSORT are shareware and your support is necessary to continue development
  26. of this product. If you find this software useful, you are obligated to
  27. register it. Please See the LICENSE section below and the registration form
  28. at the end of this file for more details. Please return the registration
  29. form, even if you decide not to pay for this package.
  30.  
  31. Your comments and suggestions are welcome. Please email comments to me at
  32. "katz@titan.fullerton.edu" I can also be reached by sending a message to
  33. "Martin Katz" on the RIME Shareware conference (private is preferred).
  34.  
  35.  
  36.                                    LICENSE
  37.  
  38. Neither the author, nor the distributors of these programs assume
  39. responsibility for any loss related directly or indirectly to the use of
  40. this product. No warranty is implied or stated, including any warranty of
  41. suitability for use. Use this product at your own risk.
  42.  
  43. If you have problems or questions, please send me a message via e-mail at
  44. katz@titan.fullerton.edu (I can also be reached on the RIME shareware
  45. conference). Please include the program name, version number (shown at the
  46. top of this file), a specific explanation of your problem, and your e-mail
  47. address.
  48.  
  49. These programs may be freely distributed provided that they are not
  50. changed, this file is included, and that no charge is made for this
  51. software, except for media costs (limited to less than $10).
  52.  
  53. All distribution must include the following files:
  54.    MSORT.DOC,
  55.    MSORT.EXE, and
  56.    SSORT.EXE.
  57.  
  58. The following additional files are included for convenience:
  59.    FILE_ID.DIZ,
  60.    HISTORY,
  61.    README,
  62.    REGISTER.FRM,
  63.    SORTTAGS.BAT, and
  64.    TESTFILE.COM.
  65.  
  66.  
  67.                            USING SSORT and MSORT
  68.  
  69. You use the programs SSORT and MSORT in the same way. SSORT is faster, but
  70. cannot sort large files (the data must all fit in memory). If SSORT cannot
  71. sort your file, please use MSORT. This section will show SSORT in the
  72. examples, but you can use MSORT the same way.
  73.  
  74. SSORT and MSORT assume that each line in your file ends with a line-feed
  75. character (carriage-returns are ignored). Formatting and control characters
  76. used in word processors should not be included in the input file (they are
  77. just treated as characters to sort).
  78.  
  79. The simplest way to sort two files is
  80.     SSORT (input file) (output file)
  81.  
  82. where (input file) and (output file) are file names. For example, to sort
  83. the file PHONE.BOK and output to PHONE.SRT you would type
  84.     SSORT PHONE.BOK PHONE.SRT
  85.  
  86. SSORT can also take its input from the DOS standard input and output to DOS
  87. standard output (this is the manner required by the standard DOS sort
  88. program). For example:
  89.    SSORT < PHONE.BOK > PHONE.SRT
  90.  
  91. WARNING: If you use redirection, the input and output files must always
  92.          be different. Otherwise, the input file will be destroyed. Use
  93.          of the DOS SHARE program (or MS Windows) will prevent this
  94.          destruction of data.
  95.  
  96.  
  97.                                   OPTIONS
  98.  
  99. Options may begin with either a hyphen or a slash, and they may be either
  100. upper or lower case. They are shown with hyphens below for ease of reading.
  101.  
  102.  
  103. CONTROLLING THE SORTING ORDER
  104.  
  105. You can change the sorting order by using any of the following options
  106. before the file names:
  107.  
  108.     -c   Case independent. Treat all letters as if they are upper case.
  109.          Without this option, upper case comes before lower case.
  110.  
  111.     -#   Only letters will be used when comparing lines.
  112.  
  113.     -a   Only letters and digits will be used when comparing lines.
  114.  
  115.     -d   Only digits will be used when comparing lines.
  116.  
  117.     -w   Ignores spaces, tabs, etc. (Whitespace).
  118.  
  119.     -t   Ignore common short words (slow process).  This includes:
  120.          a, an, am, are, do, if, is, I, me, my, that, the, this, we, you
  121.  
  122.     -n   Sort Numerically. This means that leading a leading plus sign,
  123.          leading spaces, or leading zeroes will be ignored. If the number
  124.          begins with a negative sign, it will be considered negative. If
  125.          one of the remaining numbers is longer than the other, it is
  126.          considered larger than the other.
  127.  
  128.     -r   Sort in Reverse order
  129.  
  130.     -s   Sort by line length (size).
  131.  
  132.     +N   (N is a decimal number) Ignore characters before text column N
  133.          when comparing lines to sort. The first text column is column 1.
  134.          -+N and /+N are the same as +N.
  135.  
  136.   +N.M   (N and M are decimal numbers) Defines a field to sort beginning at
  137.          column N, and M characters wide. You may define up to 10 fields
  138.          when sorting. Later fields are only checked if the lines are equal
  139.          in earlier fields. -+N.M and /+N.M are the same as +N.M
  140.  
  141.          The sort order options (-# -a, -c, -d, -n, -r, -s,  or -w) apply
  142.          to the field specified immediately after the options. That is, you
  143.          first state the sort order options and then you define the field.
  144.          If you have more than one field, you should state the sort order
  145.          options for each.
  146.  
  147.  
  148. SIMPLE EXAMPLE
  149.  
  150. You may combine the options, but they must be separated by spaces. For
  151. example:
  152.     SSORT /C /W PHONE.BOK PHONE.SRT
  153. will sort the phone book, ignoring all spaces and tabs, and treating upper
  154. and lower case as equivalent.
  155.  
  156.  
  157. MORE COMPLETE PHONE BOOK EXAMPLE
  158.  
  159. As a more complicated example, assume that each line in the phone book
  160. begins with the name (up to 20 characters), the phone number begins at
  161. column 25, and the address begins at column 40 on the line. You might type
  162.     SSORT -c -w +1.20 -w -c +40 -d -n +25.10 PHONE.BOK PHONE.SRT
  163.  
  164. The text will be sorted by the name (columns 1-20), ignoring spaces and
  165. tabs, and treating upper and lower case as the same. If two lines contain
  166. the same name, then the addresses are compared, again ignoring spaces and
  167. treating upper and lower case as equivalent. Notice that the address field
  168. begins at column 40, because no length is specified, comparison will extend
  169. to the end of the line. If two lines are still equal, then the phone number
  170. is checked (columns 25-34). The phone number is compared numerically, and
  171. any punctuation is ignored.
  172.  
  173.  
  174. REMOVING DUPLICATE OR BLANK LINES
  175.  
  176.     -b   Remove all Blank lines from the output.
  177.  
  178.     -u   Only output Unique lines. That is, if a line appears more than
  179.          once, only output the first copy. The sort order options affect how
  180.          this option works. For example, if the -c option is given, then two
  181.          lines will be considered the same, even if one of them is all lower
  182.          case and the other is all upper case.
  183.  
  184.  
  185. ADVANCED OPTIONS
  186.  
  187. These options are provided for completeness, but should not normally be
  188. needed:
  189.  
  190.  -oNAME  Specifies the Output file name (no space is allowed between the -o
  191.          and the name).
  192.  
  193.       -  An option that is just a hyphen or slash means to read the input
  194.          from the standard input. If an output file is specified without
  195.          -o, then the output file name must come after this hyphen or slash.
  196.  
  197.     -lN  Specifies an end of line character other than line-feed. N is the
  198.          decimal ASCII code for the character to use for the line end.
  199.          There must not be a space between -l and the number. When this
  200.          option is specified, the file is assumed to be binary, not text.
  201.  
  202.  
  203.                              USING MSORT
  204.  
  205. The options for MSORT are exactly the same as the options for SSORT.
  206. SSORT tends to be somewhat faster than MSORT, but can only sort files
  207. that can be read into conventional memory.
  208.  
  209. MSORT will create two temporary files. If you set a TMP (or TEMP)
  210. environment variable the directory specified (if it exists) will be
  211. used for the temporary files. Otherwise, the current directory will be
  212. used. MSORT will fail if it cannot create these temporary files.
  213.  
  214.  
  215.                              WHY IS IT SO FAST?
  216.  
  217. MSORT is designed to use memory wisely to speed up the sorting. It uses a
  218. unique combination of methods (algorithms) that allow it to take advantage
  219. of the ordering of files that are "almost sorted," while also working well
  220. when the data is more or less random.
  221.  
  222.  
  223.                                  LIMITATIONS
  224.  
  225. SSORT is limited to files up to 16000 lines long. In addition, the program
  226. and entire file must fit in available conventional memory.
  227.  
  228. MSORT is limited by available disk space. MSORT requires disk space for the
  229. input file, the output file, and two temporary files. Thus, if the input
  230. file is N bytes long, you must have at least 3N bytes of disk space
  231. available. MSORT cannot sort files longer than two billion lines, but it is
  232. unlikely that this limit will ever be reached.
  233.  
  234. Neither MSORT nor SSORT makes use of extended or expanded memory. However,
  235. a disk cache will speed up MSORT on large files.
  236.  
  237. The length of a line should not exceed 30,000 characters.
  238.  
  239. In a network or multiprocessing environment, these programs will only work
  240. if they have the privilege of reading the input file, creating and writing
  241. to the output file, and (in the case of MSORT) creating, reading, and
  242. writing to the temporary files.
  243.  
  244. WARNING:  The input and output files must always be different.
  245.           Otherwise, the input file can be destroyed. SSORT cannot always
  246.           detect this, so be careful. Use of the SHARE program before
  247.           running SSORT or MSORT will prevent destruction of data (SHARE is
  248.           not necessary when running MS-Windows 3.x or a multi-tasking
  249.           operating system).
  250.  
  251.  
  252.                               SORTING TAGLINES
  253.  
  254. SORTTAGS.BAT is a sample batch file that can be used to sort a file of
  255. taglines. You can use it as follows:
  256.     SORTTAGS TagsFile SortedTags
  257. That, is you give it the file name of the existing file and a filename for
  258. the sorted tags. If you do not give a name for an output file, the old file
  259. is renamed as TAGS.OLD, and the sorted output will have the same name as the
  260. original file.
  261.  
  262. SORTTAGS.BAT uses msort with the following options:
  263.     msort -# -c -t -u -b
  264.  
  265. This means:
  266.     Digits, spaces, and punctuation will be ignored (-#).
  267.  
  268.     Upper and lower case letters are considered the same (-c).
  269.  
  270.     Common small words (like "the") will be ignored (-t) -- this is a slow
  271.     process.
  272.  
  273.     If two lines are equivalent then only one of the lines will be kept in
  274.     the output (-u). Because of the other options, lines are considered
  275.     equivalent even if they differ in digits, spaces, punctuation, common
  276.     small words, or case (upper or lower).
  277.  
  278.     Finally, blank lines will be removed (-b).
  279.  
  280.  
  281. LONG TAGLINES
  282.  
  283. Some programs limit the length of taglines to 57 characters. If you sort a
  284. tagline file by length, then all of the long lines will be at the bottom.
  285. You can then use an editor to remove the long lines. You might want to keep
  286. them in a separate file. To sort a file named MYTAGS by length, you could
  287. type:
  288.     MSORT -s MYTAGS BYLENGTH.TAG
  289.  
  290. You could then edit BYLENGTH.TAG to remove the long lines. As a last step,
  291. you could use SORTTAGS to sort the remaining taglines (please make a backup
  292. before sorting):
  293.     COPY MYTAGS MYTAGS.BAK
  294.     SORTTAGS BYLENGTH.TAG MYTAGS
  295.     DEL BYLENGTH.TAG
  296.  
  297.  
  298.                               TESTFILE PROGRAM
  299.  
  300. The TESTFILE program is a small utility for creating files of numbered
  301. lines. These files are useful for testing sorting and editing programs.
  302. The program has no command line arguments and outputs to standard output.
  303.  
  304. Here is a sample execution of the program:
  305.   C:\MSORT> TESTFILE > TEST
  306.  
  307.   Enter first number to print (0...99999999): 1
  308.   Enter last  number to print (0...99999999): 10
  309.   Enter minimum width of numbers to print (0...10): 3
  310.   Enter minimum line width in characters (0...1024): 40
  311.   Enter maximum line width in characters (0...1024): 40
  312.   Enter the ASCII value of character to fill out the line with: 46
  313.  
  314. This creates a file called TEST that contains ten lines (1 - 10). Each line
  315. will be exactly 40 characters long. Since the lines are long enough, each
  316. line will begin and end with the line number. The line numbers will be
  317. padded out on the left with zeros. The space between the line numbers will
  318. be filled by periods (ASCII 46). The TEST file will look like this:
  319.  
  320. 001..................................001
  321. 002..................................002
  322. 003..................................003
  323. 004..................................004
  324. 005..................................005
  325. 006..................................006
  326. 007..................................007
  327. 008..................................008
  328. 009..................................009
  329. 010..................................010
  330.  
  331.  
  332.                               ABOUT THE AUTHOR
  333.  
  334. Martin Katz is a Professor of Computer Science at California State
  335. University, Fullerton. His specialties include advanced user interfaces,
  336. software engineering, data structures and algorithms, and programming
  337. languages. He teaches a wide variety of courses for students with varying
  338. backgrounds. As a consultant to industry, Dr. Katz has been involved in
  339. development of a variety of software products.
  340.  
  341. E-Mail address (internet): katz@titan.fullerton.edu
  342.  
  343. _____________________________________________________________________
  344.  
  345.  
  346.                     MSORT/SSORT for DOS  (version 1.12)
  347.                              REGISTRATION FORM
  348.  
  349. This program is not free, it is shareware. Shareware programs are
  350. distributed on the honor system, assuming that honorable users will pay for
  351. the product if it is found to be useful.  If you like the program you are
  352. obligated to register it within 30 days. Registration will support
  353. development of future shareware products.
  354.  
  355. Please type or print clearly:
  356.  
  357. MAIL TO:                           FROM:
  358. Martin Katz, Ph.D.                 Name: __________________________________
  359. 6452 Adobe Circle Road, South
  360. Irvine, CA  92715               Address: __________________________________
  361.  
  362.                                    City: __________________________________
  363.  
  364.                         State, ZIP Code: __________________________________
  365.  
  366.                      Country if not USA: __________________________________
  367.  
  368.                 Company (if applicable): __________________________________
  369.  
  370.                         Daytime Phone #: __________________________________
  371.  
  372.                       Registration date: __________________________________
  373.  
  374.  
  375.                              REQUESTED DONATION
  376.  
  377. Personal, educational, or nonprofit use          $10.00 (one computer)
  378. Nonprofit site license (any number of users)    $100.00
  379.  
  380. Commercial use                                   $50.00 (per computer)
  381. Commercial site-license (any number of users)   $500.00
  382.  
  383. TOTAL ENCLOSED US FUNDS                   US $______.____
  384.  
  385. Please send this form with a check or money order (drawn on a USA bank),
  386. made out to "Martin Katz, Ph.D." Sorry, no credit cards or purchase orders
  387. accepted.  Please do not send cash through the mail.
  388.